import java.io.*;

public class Test2 {
    public static void main(String[] args) throws IOException {
        String fileName = "D:\\Java\\Hello.txt";

        FileWriter writer = new FileWriter(fileName, true);//已有文件后续写而不是完全替代

        writer.write("Hello!\n");
        writer.write("This is my first text file,\n");
        writer.write("You can see how this is done.\n");
        writer.write("输入一行中文也可以\n");
        writer.write("haha\n");
        writer.close();

    }
}
